/*
 * Name: Joon Ho Cho
 * Date: 10/24/2008
 * Course: 15-437
 */
package scheduler.model;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;

import scheduler.model.BookmarkDao;
import scheduler.model.BookmarkDaoBeanFactoryImpl;
import scheduler.model.UserDao;
import scheduler.model.UserDaoBeanFactoryImpl;

public class Model {
    private BookmarkDao bookmarkDao;
    private UserDao  userDao;

	public Model(ServletConfig config) throws ServletException {
		try {
		    String jdbcDriver = config.getInitParameter("jdbcDriverName");
		    String jdbcUrl    = config.getInitParameter("jdbcURL");
	    	    
		    bookmarkDao = new BookmarkDaoBeanFactoryImpl(jdbcDriver, jdbcUrl);
		    userDao = new UserDaoBeanFactoryImpl(jdbcDriver, jdbcUrl);
		} catch (Throwable t) {
		    throw new ServletException(t);
		}
	}

    public BookmarkDao getBookmarkDao() {
        return bookmarkDao;
    }

    public UserDao getUserDao() {
        return userDao;
    }
}
